This Post Has been moved to --> ASP DOT NET MATTERS
Monday, February 16, 2009
About JSON
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
JSON is built on two structures:
* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
Kindly click on following link for more information. I find JSON much more useful for Ajax operations since parsing is easy like an XML.
check it : http://json.org/
Labels:
JSON
Saturday, February 14, 2009
Ajaxified Grid 1
Use of ICallbackEventHandler may not be the good option to make grid Ajax enabled
In this post I will discuss following
In this post I will discuss following
- Sort the grid in ascending or in descending order by clicking on the arrows next to column name.
- Change pages of the grid.
- Change page length of the gird
We will used RenderControl function to get HTML.
Using this function of control we are able to get HTML of that control., but for this we will have to use HtmlTextWriter and StringWriter as follows
e.g.
Here result will contain HTML format of the grid control. We will convert grid control to HTML after binding the data.
We will start developing the UI and code in following steps
Simply copy paste following code in the tag of the page
Since we can register this function by using “Page.ClientScript.RegisterClientScriptBlock” If we register above function using this that function will appear in tag only.
This function will be fired after server sends response back to client, thus this function will manipulate server response. We have simply put the response as innerHTML of the Div tag. This innerHTML contains HTML format of the updated grid.
Server-Side functions are as follows
This function simply returns the result which we have put as innerHTML in ShowResult function (Refer previouse point)
In this function eventArgument will appear as “changePage$1$10” or “sort$1$10” or “changePageLength$1$10” or “sort$Contact Name Asc$10” or “sort$Contact Name Desc$10”
If we split this on “$”, we will get
- Action .
- Page index of the Grid.
- Page size from the dropdown list (i.e. id is ‘ddl’).
(In changePageLength we don’t need args[2]; I have kept is just to makecoding little simple)
In RaiseCallbackEvent we have simply called the function which we have decleared in POINT 3, each function in point 3 will do the respective action and return a HTML string of the Grid.
Add following code protected void Page_Load(object sender, EventArgs e)
[At this point if we compile the code we will able to chage the page length ]
Now we will write code in the RowDataBound event of the Grid.. I.e. in protected void _grid_RowDataBound(object sender, GridViewRowEventArgs e)
For adding columnwise sorting functionality in grid, we will modify columnheader row of the grid.
We have added Up and down images and onclick of either of them we have called UpdateGrid function (Ref. Point 4) , for sorting Ascending and Descending order repectively. [At this point you can complie the code and the grid will be Sortable].
After this we will modify the Pager row in such a way that we can use it to change the page index of the grid using UpdateGrid function.(Ref. point 4 public void RaiseCallbackEvent)
_pageCount contains the pagecount of the grid. We have to display pages as Numbers so we used HyperLink and Label to add space after each page number. We can choose our own way to display pages, just we will have to take care of adding the attribute of JavaScript.
And now we have created an Ajax enabled grid using ICallbackEventHandler.
(Don’t forget to Add ICallbackEventHandler).
Labels:
Ajax,
Asp.net,
Grid Handling,
ICallback
Thursday, February 12, 2009
get HTML - of serverside control for Ajax handling
This post is moved to
ASP DOT NET MATTERS
Click on Above Link to Get Redirect to Desired Page.
Direct Blog address : http://www.aspdotnetmatters.blogspot.com
ASP DOT NET MATTERS
Click on Above Link to Get Redirect to Desired Page.
Direct Blog address : http://www.aspdotnetmatters.blogspot.com
Labels:
General
Monday, February 2, 2009
Ajax-Handle complex data type
This Post is Moved to
Asp Dot Net Matters
Click on Above like to redirect to Desired page.
Check blog: http://www.aspdotnetmatters.blogspot.com
Asp Dot Net Matters
Click on Above like to redirect to Desired page.
Check blog: http://www.aspdotnetmatters.blogspot.com
Subscribe to:
Posts (Atom)